package com.twu.biblioteca.ui;

public class MenuItem {
    private final static IAvailableChecker trueChecker = new IAvailableChecker() {
        @Override
        public boolean isAvailable() {
            return true;
        }
    };
    private final String name;
    private final IActuator actuator;
    private final IAvailableChecker checker;

    public MenuItem(String name, IActuator actuator) {
        this.name = name;
        this.actuator = actuator;
        this.checker = trueChecker;
    }

    public MenuItem(String name, IActuator actuator, IAvailableChecker checker) {
        this.name = name;
        this.actuator = actuator;
        this.checker = checker;
    }

    public String getName() {
        return name;
    }

    public void actuate() {
        this.actuator.actuate();
    }

    public boolean isAvailable() {
        return checker.isAvailable();
    }
}
